'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { merchantjoinService } from '../service/merchantjoin';

/** 餐厅入住api对象 */
@prefix('merchantjoin')
class MerchantjoinController {
    /**
     * 
     * @api {post} /merchantjoin/query  查询餐厅入住记录
     * @apiDescription 查询餐厅入住记录
     * @apiName query
     * @apiParam (参数) {String} offset   页码
     * @apiParam (参数) {String} limit    每页显示条数
     * @apiSampleRequest /merchantjoin/query
     * @apiGroup merchantjoin
     * @apiVersion 1.0.0
     */
    @router('/query', { method: 'post' })
    async query(ctx: Koa.Context) {
        let result = await merchantjoinService.query(ctx.request.body);
        response(ctx, result);
    }
    /**
     * 
     * @api {post} /merchantjoin/save  保存餐厅入住信息
     * @apiDescription 保存餐厅入住信息
     * @apiName save
     * @apiParam (参数) {String} token   当前用户token
     * @apiParam (参数) {String} merchantname   餐厅名称
     * @apiParam (参数) {String} area   所在区域
     * @apiParam (参数) {String} phone   联系电话
     * @apiParam (参数) {String} name    联系人
     * @apiParam (参数) {String} certificate    证书图片id
     * @apiParam (参数) {String} remarks    备注
     * @apiSampleRequest /merchantjoin/save
     * @apiGroup merchantjoin
     * @apiVersion 3.0.0
     */
    @router('/save', { method: 'post' })
    async save(ctx: Koa.Context) {
        let result = await merchantjoinService.save(ctx.request.body);
        response(ctx, result);
    }


    @router('/updatestatus', { method: 'post' })
    async updatestatus(ctx: Koa.Context) {
        let result = await merchantjoinService.updatestatus(ctx.request.body);
        response(ctx, result);
    }


    @router('/querybyId', { method: 'post' })
    async querybyId(ctx: Koa.Context) {
        let result = await merchantjoinService.queryById(ctx.request.body);
        response(ctx, result);
    }

    /**
     * 
     * @api {post} /merchantjoin/queryByCode  查询餐厅入驻信息（小程序）
     * @apiDescription 查询餐厅入驻信息（小程序）
     * @apiName queryByCode
     * @apiParam (参数) {String} token  用户token
     * @apiSampleRequest /merchantjoin/queryByCode
     * @apiGroup merchantjoin
     * @apiVersion 3.0.0
     */
    @router('/queryByCode', { method: 'post' })
    async queryByCode(ctx: Koa.Context) {
        let result = await merchantjoinService.queryByCode(ctx.request.body.token);
        response(ctx, result);
    }
}